import pygame
import numpy as np
class Graph(object):
    def __init__(self,screen_size,unit):
        self.width,self.height = screen_size
        self.unit = unit
        self.m,self.n = self.width // unit, self.height // unit
        self.line_width = 1
        self.mat = np.ones((self.m, self.n))
        self.obstacle = [] #[(x_i, y_i)]
    def draw(self,screen):
        line_color = (0,0,0)
        for x in range(self.unit, self.height, self.unit):
            pygame.draw.line(screen,line_color,(x,0), (x, self.height), self.line_width)
        for y in range(self.unit, self.width, self.unit):
            pygame.draw.line(screen, line_color,(0,y),(self.width,y), self.line_width)


    def constraint(self,x,y):
        #if (point[0] >= 0 and point[0] < self.m) and (point[1] >= 0 and point[1] < self.n):
        if (x >= 0 and x < self.m) and (y >= 0 and y < self.n):
            return True
        else:
            return False
    def set_obstacle(self,obstacle):
        self.obstacle = obstacle
        for (x,y) in self.obstacle:
            self.mat[x][y] = 0
    def dis_mat(self):
        print(self.mat)
